from selenium import webdriver
from selenium.webdriver.common.by import By
import time

url = 'http://www.baidu.com'
driver = webdriver.Edge()
driver.get(url)
# 通过xpath、css选择器、name属性值、class属性值定位元素
# driver.find_element(By.XPATH,'//*[@id="kw"]').send_keys('python3')
# driver.find_element(By.CSS_SELECTOR,'#kw').send_keys('python3')
# driver.find_element(By.NAME,'wd').send_keys('python3')
# driver.find_element(By.CLASS_NAME,'s_ipt').send_keys('python3')

# driver.find_element(By.ID,'su').click()
# 通过链接文本进行元素定位
# driver.find_element(By.LINK_TEXT,'hao123').click()
# 通过部分链接文本进行元素定位（取代上面的方法）
driver.find_element(By.PARTIAL_LINK_TEXT,'hao').click()
time.sleep(20)
driver.close()